<html>
<head><meta charset="utf-8"><title>automatic git project locating in a local path · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/automatic.20git.20project.20locating.20in.20a.20local.20path.html">automatic git project locating in a local path</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="236334117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/automatic%20git%20project%20locating%20in%20a%20local%20path/near/236334117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/automatic.20git.20project.20locating.20in.20a.20local.20path.html#236334117">(Apr 27 2021 at 13:17)</a>:</h4>
<p>When we point to a git repository on GitHub as a dependency, Cargo searches through the repository to find the right Cargo.toml. When I check out a git repository locally and point to it with <code>path</code>, it doesn't do that same search. When I point to the local checkout with <code>git</code>, it appears to still clone it from my local path into my <code>~/.cargo</code>. </p>
<p>Is there a way to do the search locally and not duplicate the repository?</p>



<a name="236340713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/automatic%20git%20project%20locating%20in%20a%20local%20path/near/236340713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/automatic.20git.20project.20locating.20in.20a.20local.20path.html#236340713">(Apr 27 2021 at 13:55)</a>:</h4>
<p>This is the first time I've heard someone wanting the search behavior, usually I hear people want to avoid the search.</p>
<p>In theory you can use a <a href="https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#paths-overrides">paths override</a> which also has the recursive search behavior. However, <code>paths</code> can be finicky and don't work very well.</p>
<p>Otherwise, I don't think anything else will search like that.</p>



<a name="236341743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/automatic%20git%20project%20locating%20in%20a%20local%20path/near/236341743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/automatic.20git.20project.20locating.20in.20a.20local.20path.html#236341743">(Apr 27 2021 at 14:01)</a>:</h4>
<p>You can point to the local git directory with a git:// path perhaps?</p>



<a name="236341850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/automatic%20git%20project%20locating%20in%20a%20local%20path/near/236341850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/automatic.20git.20project.20locating.20in.20a.20local.20path.html#236341850">(Apr 27 2021 at 14:02)</a>:</h4>
<p>in theory at least git itself doesn't really differentiate between remote and local sources, not sure if cargo does</p>



<a name="236341919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/automatic%20git%20project%20locating%20in%20a%20local%20path/near/236341919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/automatic.20git.20project.20locating.20in.20a.20local.20path.html#236341919">(Apr 27 2021 at 14:02)</a>:</h4>
<p>Yea, you can use <code>git={"file:///..."}</code>, but when you do that Cargo still copies the entire git repo (very slowly), and I think shepmaster wanted to avoid that copy.</p>



<a name="236342019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/automatic%20git%20project%20locating%20in%20a%20local%20path/near/236342019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/automatic.20git.20project.20locating.20in.20a.20local.20path.html#236342019">(Apr 27 2021 at 14:03)</a>:</h4>
<p>Ah. Yeah, that might be a problem</p>



<a name="236342075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/automatic%20git%20project%20locating%20in%20a%20local%20path/near/236342075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/automatic.20git.20project.20locating.20in.20a.20local.20path.html#236342075">(Apr 27 2021 at 14:03)</a>:</h4>
<p>(I wonder if we could setup "shared" git repos via some flag, so this works well)</p>



<a name="236392378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/automatic%20git%20project%20locating%20in%20a%20local%20path/near/236392378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> XAMPPRocky <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/automatic.20git.20project.20locating.20in.20a.20local.20path.html#236392378">(Apr 27 2021 at 19:11)</a>:</h4>
<p>FWIW, I’ve also often wanted cargo to perform the search for local deps (though I guess I didn’t think it was a file search, I thought it just read the root Cargo.toml and picked the picked the package from the workspace members).</p>
<p>I run into this most often when I’m testing a new version of a git dependency in a project with a local version.</p>



<a name="236394616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/automatic%20git%20project%20locating%20in%20a%20local%20path/near/236394616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/automatic.20git.20project.20locating.20in.20a.20local.20path.html#236394616">(Apr 27 2021 at 19:27)</a>:</h4>
<blockquote>
<p>This is the first time I've heard someone wanting the search behavior</p>
</blockquote>
<p>Specifically, I'm writing a mini/inverse crater tool. I want to update SNAFU and see what downstream consumers break and to test if my automated migration tool works. My current flow is:</p>
<ol>
<li>get reverse dependencies from <a href="http://crates.io">crates.io</a></li>
<li>check out their repository</li>
<li>add it as a dependency to a little project</li>
<li>build</li>
<li>patch in my local changes</li>
<li>build</li>
</ol>
<p>Adding it as a dependency is annoying because it might not be at the root of their repo.</p>
<p>However, having my local changes sounds like it rules out the path-based overrides:</p>
<blockquote>
<p>You cannot use this feature to tell Cargo how to find local unpublished crates.</p>
</blockquote>



<a name="236495178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/automatic%20git%20project%20locating%20in%20a%20local%20path/near/236495178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/automatic.20git.20project.20locating.20in.20a.20local.20path.html#236495178">(Apr 28 2021 at 12:10)</a>:</h4>
<p>A quick bit of <code>walkdir</code> + <code>serde</code> + Iterator magic was able to get me going, at least.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>